/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package soundcontrol.soap;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import soundcontrol.SoundControl;
/**
 *
 * @author Lianowar
 */
public class PlayThread implements Runnable{
    
    private String File = "";

    public String getFile() {
        return File;
    }
    private Player p ;

    public Player getP() {
        return p;
    }
    
    
    
    
    public PlayThread(String File)
    {
        this.File = File;
    }
    
    @Override public void run()
    {
        FileInputStream in = null;
        try {
            if(this.File != null)
            {
            System.out.print("Play");
            String path = SoundControl.configFile.getProperty(this.File);
            File dir = new File(path);
            in = new FileInputStream(dir);
            // Player-Instanz
            p= new Player(in);
            System.out.print(p.toString());
            // Abspielen
            p.play();
            }
            
        } catch (JavaLayerException ex) {
            Logger.getLogger(PlayThread.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(PlayThread.class.getName()).log(Level.SEVERE, null, ex);
        } finally
        {
            try {
                in.close();
            } catch (IOException ex) {
                Logger.getLogger(PlayThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
  

   
            
}
